from pydantic import BaseModel
from pydantic_settings import BaseSettings
import yaml

DeepSeek = "DeepSeek"
apiKey = "apiKey"

class DeepSeekConfig(BaseModel):
    apiKey: str

class AppConfig(BaseModel):
    name: str
    timeout: int


class ApplicationConfig(BaseSettings):
    deepSeek: DeepSeekConfig
    app: AppConfig

    @classmethod
    def load_config(cls, config_path: str = "./application.yml"):
        # 读取 YAML 文件
        with open(config_path, "r") as f:
            config_data = yaml.safe_load(f)
        return config_data

# 加载全局配置
config = ApplicationConfig.load_config()

# 读取相关配置
apiKey = str(config[DeepSeek][apiKey])